/**
 *====================================================
* 文件名称: InsuranceCoverageServiceImpl.java
 * 修订记录：
  * No    日期				作者(操作:具体内容)
  * 1.    2015年12月09日	chenxy(创建:创建文件)
  *====================================================
  * 类描述：(说明未实现或其它不应生成javadoc的内容)
  */
package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.common.util.BeanUtils;
import com.yuexunit.finance.project.entity.InsuranceCoverageEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;

/**
 * @ClassName: InsuranceCoverageServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年12月09日 11:07:15
 */
@Implements(InsuranceCoverageService.class)
public class InsuranceCoverageServiceImpl implements InsuranceCoverageService {

	@Override
	public Long createInsuranceCoverage(InsuranceCoverageEntity entity) {
		PersistUtil.insert(entity);
		return entity.getInsuranceCoverageId();
	}

	@Override
	public void updateInsuranceCoverage(InsuranceCoverageEntity entity) {
		InsuranceCoverageEntity persist = inquireInsuranceCoverage(entity.getInsuranceCoverageId());
		BeanUtils.copyProperties(persist, entity);
		PersistUtil.update(persist);
	}

	@Override
	public void renovateInsuranceCoverage(InsuranceCoverageEntity persist) {
		PersistUtil.update(persist);
	}

	@Override
	public void deleteInsuranceCoverage(InsuranceCoverageEntity persist) {
		PersistUtil.delete(persist);
	}

	@Override
	public InsuranceCoverageEntity inquireInsuranceCoverage(Long insuranceCoverageId) {
		return PersistUtil.get(InsuranceCoverageEntity.class, insuranceCoverageId);
	}

	@Override
	public List<InsuranceCoverageEntity> inquireInsuranceCoverageList(Long insuranceId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(InsuranceCoverageEntity.class);
		criteria.add(Restrictions.eq("insuranceId", insuranceId));
		return PersistUtil.get(criteria);
	}

	@Override
	public List<InsuranceCoverageEntity> inquireInsuranceCoverageByCoverageName(
			String coverageName) {
		DetachedCriteria criteria = DetachedCriteria.forClass(InsuranceCoverageEntity.class);
		criteria.add(Restrictions.like("coverageName", "%"+coverageName+"%"));
		return PersistUtil.get(criteria);
	}

}
